import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '/ucenter',
    component: Layout,
    redirect: '/ucenter/user',
    name: 'Ucenter',
    meta: { title: '成员管理', icon: 'user0' },
    children: [
      {
        path: 'user',
        name: 'User',
        component: () => import('@/views/ucenter/user'),
        meta: { title: '用户', icon: 'user1' }
      },
      {
        path: 'teacher',
        name: 'Teacher',
        component: () => import('@/views/ucenter/teacher'),
        meta: { title: '讲师', icon: 'teacher' }
      },
      {
        path: 'teacherApply',
        name: 'teacherApply',
        component: () => import('@/views/ucenter/teacherApply'),
        meta: { title: '讲师申请', icon: 'apply' }
      },
      {
        hidden: true,
        path: 'teacherApplyInfo:/id',
        name: 'teacherApplyInfo',
        component: () => import('@/views/ucenter/teacherApplyInfo'),
        meta: { title: '讲师申请详情', icon: 'teacher' },
        props: true,
      },
      {
        hidden: true,
        path: 'userInfo/:id',
        name: 'userInfo',
        component: () => import('@/views/ucenter/userInfo'),
        meta: { title: '用户详情', icon: 'teacher' },
        props: true,
      },
      {
        hidden: true,
        path: 'teacherInfo/:id',
        name: 'teacherInfo',
        component: () => import('@/views/ucenter/teacherInfo'),
        meta: { title: '讲师详情', icon: 'teacher' },
        props: true,
      }
    ]
  },

  {
    path: '/course',
    component: Layout,
    redirect: '/course/course',
    name: 'Example',
    meta: { title: '课程管理', icon: 'example' },
    children: [
      {
        path: 'subject',
        name: 'Subject',
        component: () => import('@/views/course/subject'),
        meta: { title: '课程分类', icon: 'tree' }
      }, {
        path: 'course',
        name: 'Course',
        component: () => import('@/views/course/course'),
        meta: { title: '课程管理', icon: 'course' }
      }, {
        path: 'course-add',
        name: 'CourseAdd',
        component: () => import('@/views/course/courseAdd/index'),
        hidden: true,
        meta: { title: '课程信息', icon: 'course' },
        props: true,
      }
    ]
  },

  {

    path: '/classroom',
    component: Layout,
    redirect: '/classroom/room',
    name: 'Classroom',
    meta: { title: '班级管理', icon: 'classroom' },
    children: [
      {
        path: 'room',
        name: 'Room',
        component: () => import('@/views/classroom/room'),
        meta: { title: '班级管理', icon: 'room' }
      },
      {
        path: 'classUser',
        name: 'ClassUser',
        component: () => import('@/views/classroom/classUser'),
        meta: { title: '班级学员', icon: 'room' },
        hidden: true,
        props: true,
      },
      {
        path: 'classCourse',
        name: 'ClassCourse',
        component: () => import('@/views/classroom/classCourse'),
        meta: { title: '班级课程', icon: 'room' },
        hidden: true,
        props: true,
      },
      {
        path: 'classCourseMange',
        name: 'ClassCourseMange',
        component: () => import('@/views/classroom/classCourseAdd/index'),
        meta: { title: '课程信息', icon: 'room' },
        hidden: true,
        props: true,
      },
    ]
  },

  {
    path: '/cms',
    component: Layout,
    redirect: '/cms/banner',
    name: 'Cms',
    meta: { title: 'cms管理', icon: 'cms' },
    children: [
      {
        path: 'banner',
        name: 'Banner',
        component: () => import('@/views/cms/banner'),
        meta: { title: 'Banner管理', icon: 'banner' }
      },
      {
        path: 'info',
        name: 'BannerInfo',
        component: () => import('@/views/cms/info'),
        meta: { title: 'Banner详情', icon: 'banner' },
        hidden: true,
        props: true,
      },

    ]
  },
  {
    path: '/statistic',
    component: Layout,
    redirect: '/statistic/statistic-daily',
    name: 'Statistic',
    meta: { title: '统计', icon: 'statistic' },
    children: [
      {
        path: 'statistic-daily',
        name: 'StatisticDaily',
        component: () => import('@/views/statistic/StatisticDaily'),
        meta: { title: '日常统计', icon: 'statistic-daily' }
      },
      {
        path: 'statistic-job',
        name: 'StatisticJob',
        component: () => import('@/views/statistic/StatisticJob'),
        meta: { title: '定时任务', icon: 'job' }
      },

    ]
  },
  {
    path: '/push',
    component: Layout,
    redirect: '/push/course',
    name: 'Push',
    meta: { title: '推送计划', icon: 'push' },
    children: [
      {
        path: 'course',
        name: 'CoursePush',
        component: () => import('@/views/push/course'),
        meta: { title: '课程推送', icon: 'course' }
      },
      {
        path: 'classroom',
        name: 'ClassroomPush',
        component: () => import('@/views/push/classroom'),
        meta: { title: '班级推送', icon: 'room' }
      },

    ]
  },
  {
    path: '/acl',
    component: Layout,
    redirect: '/acl/menu/list',
    name: '权限管理',
    meta: { title: '权限管理', icon: 'acl' },
    children: [
      {
        path: 'role/list',
        name: '角色管理',
        component: () => import('@/views/acl/role/list'),
        meta: { title: '角色管理', icon: 'role' }
      },
      {
        path: 'role/form',
        name: '角色添加',
        component: () => import('@/views/acl/role/form'),
        meta: { title: '角色添加' },
        hidden: true
      },
      {
        path: 'role/update/:id',
        name: '角色修改',
        component: () => import('@/views/acl/role/form'),
        meta: { title: '角色修改' },
        hidden: true
      },
      {
        path: 'role/distribution/:id',
        name: '角色权限',
        component: () => import('@/views/acl/role/roleForm'),
        meta: { title: '角色权限' },
        hidden: true
      },
      {
        path: 'menu/list',
        name: '菜单管理',
        component: () => import('@/views/acl/menu/list'),
        meta: { title: '菜单管理', icon: 'menu' }
      },

    ]
  },





  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
